package com.example.modellol.Fragment;


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;


import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.modellol.R;
import com.example.modellol.adapter.MyAdapter2;
import com.example.modellol.bean.News;

import java.util.ArrayList;


public class ThirdFragment extends Fragment {
    private View view;
    public RecyclerView mCollectRecyclerView;
    private ArrayList<News> goodsEntityList = new ArrayList<News>();
    private MyAdapter2 mCollectRecyclerAdapter;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.item_match, container, false);
        initRecyclerView();
        initData();
        return view;
    }


    int[] c =new int[]{R.drawable.match_1, R.drawable.match_2,
            R.drawable.match_3, R.drawable.match_4,
            R.drawable.match_5, R.drawable.match_6};

    String[] d=new String[]{"LPL赛事没品图：乐爷版猛龙咆哮，阿Bin头发自由飞翔","SN2:0 RW Huanfeng卡莎疯狂收割17次击杀",
            "【2021春季赛】 《S-LOG 03》 --逆流而上","RA 2:0 V5 iBoy小炮爆炸输出RA豪取8连胜","LPL春季赛3月11日首发名单，Scout中路交手icon",
            "破防了！V5与RW接连被翻 马老师：我真的头晕了 太离谱了"
    };


    String[] a=new String[]{"LPL赛事没品图","大电竞LOL",
            "苏宁电竞俱乐部","大电竞LOL","英雄联盟赛事官方",
            "落夜电竞",
    };

    String[] b=new String[]{"53","86",
            "14","121","32",
            "3",
    };

    private void initData() {
        goodsEntityList.clear();
        for(int i=0;i<6;i++){
            News goodsEntity=new News();
            goodsEntity.setText_one(d[i]);
            goodsEntity.setText_two(a[i]);
            goodsEntity.setText_three(b[i]);
            goodsEntity.setImgPath_one(R.drawable.icon_lol_tb);
            goodsEntity.setImgPath_two(c[i]);
            goodsEntityList.add(goodsEntity);
        }
    }

    private void initRecyclerView() {
        mCollectRecyclerView = (RecyclerView) view.findViewById(R.id.n_recycle);
        mCollectRecyclerAdapter = new MyAdapter2(getActivity(), goodsEntityList);
        mCollectRecyclerView.setAdapter(mCollectRecyclerAdapter);
        mCollectRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
        mCollectRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
        mCollectRecyclerAdapter.setOnItemClickListener(new MyAdapter2.OnItemClickListener() {
            @Override
            public void OnItemClick(View view, News data) {
                Toast.makeText(getActivity(), "我是item", Toast.LENGTH_SHORT).show();
            }
        });
    }
}